<!DOCTYPE html>
<script src="../../resources/js-test.js"></script>
<script>
description("Must not crash, and transforms to 'data 1breakdata 2'. Test for http://crbug.com/530587.");

var parser = new DOMParser();
var doc = parser.parseFromString('<?xml version="1.0" encoding="UTF-8"?><root><parameter name="DICTIONARY">data 1\ndata 2</parameter></root>', 'text/xml');
var xslt = parser.parseFromString('<?xml version="1.0" encoding="utf-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:output method="text" indent="no" omit-xml-declaration="yes" encoding="utf-8"/><xsl:template match="/"><xsl:apply-templates select="root/*"/></xsl:template><xsl:template match="node()"><xsl:call-template name="Replace"><xsl:with-param name="text" select="."/></xsl:call-template></xsl:template><xsl:template name="Replace"><xsl:param name="text"/><xsl:choose><xsl:when test="contains($text, $linebreak)"><xsl:value-of select="substring-before($text, $linebreak)"/><xsl:text>break</xsl:text><xsl:call-template name="Replace"><xsl:with-param name="text" select="substring-after($text, $linebreak)"/></xsl:call-template></xsl:when><xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise></xsl:choose></xsl:template><xsl:variable name="linebreak" xml:space="preserve">\n</xsl:variable></xsl:stylesheet>', 'text/xml');
var processor = new XSLTProcessor();
processor.importStylesheet(xslt);

shouldBe('processor.transformToFragment(doc, document).textContent', '"data 1breakdata 2"');
</script>
